// source --> https://signatureplaces.com/wp-content/themes/storefront-child-theme-new/main.js?ver=5.4.2
$ = jQuery;
window.isMobile = window.matchMedia("only screen and (max-width: 991px)").matches;
window.canLoadMore = true;
window.listingHeaderPhoto = 0;
window.containerWidth = 0;
window.slctd_cat_ids = [];
window.slctd_sort_setting = "";
window.lastDrtView = false;
$.fn.isInViewport = function() {
if ($(this).length) {
var elementTop = $(this).offset().top;
var elementBottom = elementTop + $(this).outerHeight();
var viewportTop = $(window).scrollTop();
var viewportBottom = viewportTop + $(window).height();
return elementBottom > viewportTop && elementTop < viewportBottom;
}
};
$(document).ready(function() {
if ("undefined" !== typeof DRTS) {
DRTS.scrollTo = function (target) {
if ($(".collection-tabs").length) {
var top = $(".collection-tabs:first").offset().top - 100;
} else if ($(".ad_container").length) {
var top = $(".ad_container:first").offset().top - 150;
} else {
if ($(".places-of-destination").length) {
var top = $(".places-of-destination .drts-main:first").offset().top - $("#wpadminbar").outerHeight() - 80;
} else {
var top = $(".drts-main:first").offset().top - $("#wpadminbar").outerHeight() - 80;
}
}
$([document.documentElement, document.body]).animate({
scrollTop: top
}, 1000);
};
}
if ($(".mgbutton.moove-gdpr-modal-save-settings").length) {
$(".mgbutton.moove-gdpr-modal-save-settings").show();
}
if (window.isMobile && window.innerHeight < window.innerWidth) {
$(".big-hero-section").height($("#smooth_slider_1").outerHeight() + $("#smooth_slider_1 .hero-text").outerHeight());
setTimeout(function() {
$(".big-hero-section").height($("#smooth_slider_1").outerHeight() + $("#smooth_slider_1 .hero-text").outerHeight());
}, 1000);
}
if (window.isMobile && (window.innerHeight < ($(".smooth_slideri > a").innerHeight() + $(".smooth_slideri .hero-text").innerHeight() ) ) ) {
$(".big-hero-section").height($(".smooth_slideri > a").innerHeight() + $(".smooth_slideri .hero-text").innerHeight());
}
$( window ).on( "resize", function() {
$("#stickTabs").css("box-shadow", "none");
$("#stickTabs").css("border-top", "1px solid transparent");
$("#stickTabs").css("top", "unset");
$('#stickTabs').removeClass('stick');
$("#stickTabs").data("offset", false);
window.isMobile = window.matchMedia("only screen and (max-width: 991px)").matches;
if (screen.orientation == "landscape") {
$(".big-hero-section").attr("o-height", $(".big-hero-section").height());
$(".big-hero-section").height($("#smooth_slider_1").outerHeight() + $("#smooth_slider_1 .hero-text").outerHeight());
} else {
$(".big-hero-section").height($(".big-hero-section").attr("o-height"));
}
if ($(".widget-area .widget_nav_menu:hidden").length && !window.isMobile) {
$(".widget-area .drts-system-widget-directory-posts-directory--listing").show();
$(".widget-area .widget_nav_menu").show();
}
if (window.isMobile && (window.innerHeight < ($(".smooth_slideri > a").innerHeight() + $(".smooth_slideri .hero-text").innerHeight() ) ) ) {
$(".big-hero-section").height($(".smooth_slideri > a").innerHeight() + $(".smooth_slideri .hero-text").innerHeight());
}
if ($(".header-dynamic").length) {
if (window.isMobile) {
$(window).unbind("scroll").scroll(sticktothetopmobile);
sticktothetopmobile();
} else {
$('#stickThis').removeClass('stick');
$('#stickThis2').removeClass('stick');
$(window).unbind("scroll").scroll(sticktothetopdesktop);
sticktothetopdesktop();
}
$(window).scroll(function() {
loadMoreScroll();
});
}
if ($("#stickAD > .ad_container").innerWidth() > window.innerWidth / 2) {
$("#stickAD > .ad_container").css("max-width", window.innerWidth / 3);
}
if ($("#stickADsearch > .ad_container").innerWidth() > window.innerWidth / 2) {
$("#stickADsearch > .ad_container").css("max-width", window.innerWidth / 3);
}
if ($(".single.drts-entity-post .single-listing-top-area").length) {
$(".single.drts-entity-post .single-listing-top-area").height($(".entry-header").height() + $(".single.drts-entity-post .single-listing-top-area .drts-display-element-entity_field_field_excerpt-1").height());
$(".single.drts-entity-post .single-listing-top-area").css("margin-top", - parseInt($(".entry-header").height() + 6 ) + "px");
$(".single.drts-entity-post .single-listing-top-area .drts-display-element-entity_field_field_excerpt-1").css("margin-top", parseInt($(".entry-header").height()) - 48 - 32 + "px");
}
if ($("#stickTabs").length) {
$(window).scroll(function() {
sticklistingtabs();
onePageTabsScroll();
});
}
if ($("#stickAD").length || $("#stickADsearch").length) {
if ($("#stickAD").length ) {
$(window).scroll(sticklistingad);
sticklistingad();
var selector = "#stickAD";
var selector_margin = ".headline-container";
} else if ($("#stickADsearch").length ) {
$(window).scroll(sticklistingadsearch);
sticklistingadsearch();
var selector = "#stickADsearch";
var selector_margin = ".site-footer .container";
}
if (!window.isMobile) {
$(".destinations-list-with-ad-sidebar > div:nth-child(1)").css("flex", "unset");
$(".destinations-list-with-ad-sidebar > div:nth-child(1)").css("max-width", "calc(100% - "+$(selector + " > .ad_container").innerWidth()+"px - 32px)");
$(".destinations-list-with-ad-sidebar > div:nth-child(2)").css("flex", "unset");
$(".destinations-list-with-ad-sidebar > div:nth-child(2)").css("max-width", "calc("+$(selector + " > .ad_container").innerWidth()+"px )");
var or_ml = $(selector_margin).css("margin-right").replace('-','');
var marginRight = "-"+or_ml;
var marginLeft = or_ml;
$(".destlist-container").css("margin-right", marginRight);
$(".destlist-container").css("max-width", "calc("+ $(selector_margin).outerWidth() +"px + " + marginLeft.replace("px", "")+"px)");
$(".destlist-container").css("margin-left", marginLeft);
} else {
$(".destinations-list-with-ad-sidebar > div:nth-child(1)").css("flex", "0 0 100%");
$(".destinations-list-with-ad-sidebar > div:nth-child(1)").css("max-width", "100%");
$(".destinations-list-with-ad-sidebar > div:nth-child(2)").css("flex", "0 0 100%");
$(".destinations-list-with-ad-sidebar > div:nth-child(2)").css("max-width", "100%");
$(".destlist-container").css("margin-right", "auto");
$(".destlist-container").css("margin-left", "auto");
$(".destlist-container").css("max-width", "100%");
}
}
if (!$(".listing-map-link").length) {
$(".single-listing-contact-map-area-contact-form").addClass("no-map");
}
if ($(".sort-filter-container").length) {
$(window).scroll(scrollhidefilters);
}
if ($(".directory-listing-headerphoto").length) {
if (window.isMobile) {
var w_ratio = 4;
var h_ratio = 3;
} else {
var w_ratio = 16;
var h_ratio = 9;
}
$(".directory-listing-headerphoto").attr("style", "height: "+($(".directory-listing-headerphoto").outerWidth() / w_ratio * h_ratio)+"px!important");
var w = $(".directory-listing-headerphoto").outerHeight();
window.listingHeaderPhoto = w;
if (!window.isMobile) {
$(".single.drts-entity-post .drts-display-element-template-name-place_tabs").css("margin-top", w + "px");
} else {
$(".single.drts-entity-post .drts-display-element-template-name-place_tabs").css("margin-top", "0");
}
$(".single.drts-entity-post .drts-display-element.single-listing-bottom-categories.single-place-top").css("margin-top", w + "px");
$(".drts-display-element-template-name-place_image_caption").css("margin-top", w + "px");
}
$.each($(".drts-display-element-with-link"), function (i, v) {
var href = $(this).parents(".drts-row.drts-gutter-none").find(".directory-listing-title a.drts-entity-permalink").attr("href");
if (false != href) {
$(".drts-display-element-with-link")[i].onclick = null;
$(this).parents(".drts-row.drts-gutter-none").click(function(event){
var href = $(this).find(".directory-listing-title a.drts-entity-permalink").attr("href");
if (event.ctrlKey) {
window.open(href, "_blank");
} else {
window.open(href, "_top");
}
});
}
});
if ($(".featured-listing .white-bg-container").length) {
$.each($(".featured-listing .white-bg-container"), function(i, v){
$(this).height($(this).parents(".featured-listing").find(".listing-card:first").outerHeight());
});
}
});
/* BEGIN search-bar */
function openSearchBar () {
$(".js-top-search-bar").addClass("show");
$(".search-field").focus();
$(".search-field").val("");
$("body, html").addClass("noScroll");
window.scroll(0, 0);
setTimeout(function() {
window.scrollTo(0, 0);
},1);
}
function closeSearchBar () {
$(".js-top-search-bar").removeClass("show");
$("body").removeClass("noScroll");
}
$(".js-search-button").click(function(){
openSearchBar();
});
$(".js-search-bar-close").click(function(){
closeSearchBar();
});
$(".js-search-bar-overlay").click(function(){
closeSearchBar();
});
$(".js-top-search-bar .search-submit").click(function(){
$(".search-field").val("");
});
$(".js-top-search-bar .search-submit").replaceWith('');
$(".js-top-search-bar .search-field").attr("placeholder", signature_script.search);
/* END search-bar */
/* BEGIN search-results */
if ($(".js-searchresults").length) {
$(".js-searchresults .search-submit").replaceWith('');
$(".js-searchresults .search-field").attr("placeholder", signature_script.search);
}
/* END search-results */
if (!$(".listing-map-link").length) {
$(".single-listing-contact-map-area-contact-form").addClass("no-map");
$(".single-listing-contact-map-area-the-map").hide();
}
if ($(".single.drts-entity-post").length) {
if (!$(".single-listing-contact-map-area-contact-form a").length && $(".drts-display-element-template-name-single_listing_address_formatting > .drts-entity-field-value").text() == "") {
$(".single-listing-contact-map-area").hide();
$(".js-listing-tab[data-href='#contact']").remove();
}
if (!$("#makers-brands").length) {
$(".js-listing-tab[data-href='#makers-brands']").remove();
}
if (!$("#about").length || !$(".directory-listing-description").length ) {
$(".js-listing-tab[data-href='#about']").remove();
} else {
var autolinker = new Autolinker( {
urls : {
schemeMatches : true,
wwwMatches : true,
tldMatches : true
},
email : true,
phone : true,
mention : false,
hashtag : false,
stripPrefix : true,
stripTrailingSlash : true,
newWindow : true,
truncate : {
length : 0,
location : 'end'
},
replaceFn : function( match ) {
switch( match.getType() ) {
case 'url' :
//console.log( "url: ", match.getUrl() );
if ((match.getUrl()).includes("instagram.com")) {
return false;
} else {
return true; // let Autolinker perform its normal anchor tag replacement
}
}
},
className : ''
} );
$(".directory-listing-description").html(autolinker.link( $(".directory-listing-description").html() )); //TODO
}
$(".js-listing-tab:first").addClass("selected");
}
if ($(".single.drts-entity-post .single-listing-top-area").length) {
$(".single.drts-entity-post .single-listing-top-area").height($(".entry-header").height() + $(".single.drts-entity-post .single-listing-top-area .drts-display-element-entity_field_field_excerpt-1").height());
$(".single.drts-entity-post .single-listing-top-area").css("margin-top", - parseInt($(".entry-header").height() + 6 ) + "px");
$(".single.drts-entity-post .single-listing-top-area .drts-display-element-entity_field_field_excerpt-1").css("margin-top", parseInt($(".entry-header").height()) - 48 - 32 + "px");
}
if ($(".single .drts-display-element-entity_field_field_phone-1").length) {
var origin_nr = $(".single .drts-display-element-entity_field_field_phone-1 a").text();
if (!origin_nr.startsWith("+")) {
origin_nr = "+".concat(origin_nr);
}
var clean_phone = new libphonenumber.parsePhoneNumberFromString(origin_nr);
if (typeof clean_phone.formatInternational !== 'undefined') {
$(".single .drts-display-element-entity_field_field_phone-1 a").text( clean_phone.formatInternational() );
}
}
if ($(".single .drts-display-element-entity_field_field_email-1").length) {
$(".drts-entity-field .fa-envelope").removeClass("fas").addClass("far");
}
$(".newsletter-mail-input").focusout(function(){
if ($(this).val() != "") {
$(this).addClass("filled");
} else {
$(this).removeClass("filled");
}
});
if ($(".default-newsletter").length) {
$(".default-newsletter .privacy-container input").prop( "checked", false );
$(".default-newsletter .newsletter-mail-input").val("");
}
$("div[data-bg]").each(function(i, v) {
$(this).css("background-image", "url('"+$(this).attr("data-bg")+"')");
});
// Turn the given MailChimp form into an ajax version of it.
$(".mc-embedded-subscribe-form").submit(function(e) {
$form = $(this);
e.preventDefault();
if (!isValidEmail($form) || !$form.find(".privacy-container .privacy-checkbox").prop("checked")) {
var msg = signature_script.newsletter_msg_email_check;
if (!isValidEmail($form) && !$form.find(".privacy-container .privacy-checkbox").prop("checked")) {
var msg = signature_script.newsletter_msg_email_check;
} else if (!isValidEmail($form)) {
var msg = signature_script.newsletter_msg_email;
} else if (!$form.find(".privacy-container .privacy-checkbox").prop("checked")) {
var msg = signature_script.newsletter_msg_check;
}
$form.find("#mce-responses .response").hide();
$form.find("#mce-custom-response").text(msg).show();
} else {
submitSubscribeForm($form);
}
});
// Validate the email address in the form
function isValidEmail($form) {
// If email is empty, show error message.
// contains just one @
var email = $form.find("input[type='email']").val();
if (!email || !email.length) {
return false;
} else if (email.indexOf("@") == -1) {
return false;
}
return true;
}
// Submit the form with an ajax/jsonp request.
// Based on http://stackoverflow.com/a/15120409/215821
function submitSubscribeForm($form) {
$.ajax({
type: "GET",
url: $form.attr("action"),
data: $form.serialize(),
cache: false,
dataType: "jsonp",
jsonp: "c", // trigger MailChimp to return a JSONP response
contentType: "application/json; charset=utf-8",
error: function(error){
// According to jquery docs, this is never called for cross-domain JSONP requests
},
success: function(data){
if (data.result != "success") {
var message = data.msg;
if (null == data.msg) {
message = "Unable to subscribe. Please try again later.";
}
$form.find("#mce-responses .response").hide();
$form.find("#mce-error-response").text(message.replace(/(<([^>]+)>(.*?)<([^>]+)>)/,""));
$form.find("#mce-error-response").show();
} else {
$form.find(".default-newsletter").hide();
$form.find(".registered-newsletter").slideDown();
//$.cookie('name', 'hide_float_subscription_status_year', { expires: 365, path: '/' });
}
$(".default-newsletter .privacy-container input").prop( "checked", false );
$(".default-newsletter .newsletter-mail-input").val("");
}
});
}
// *** END AJAX SIGNUP ***
$('body').on("click", '#drts-modal .drts-form-buttons button[type="submit"]', function () {
window.canLoadMore = false;
window.lastDrtView = $(".drts-view-entities-container:last").html();
$('.drts-view-entities-container').css("transition",'opacity 0.5s ease-in-out');
$('.drts-view-entities-container').css("opacity","0.5");
setTimeout(function(){
updateDrts();
}, 300);
});
function updateDrts () {
if ($(".drts-view-entities-container:last").html() != window.lastDrtView) {
var loading_url = $(".drts-view-entities-container:last-of-type .drts-pagination .drts-bs-btn-outline-secondary.drts-bs-active + .drts-bs-btn-outline-secondary").data("url");
$(".sp_loadmore a").data("url", loading_url);
if ($("body.single-destinations_dir_ltg").length) {
$(".places-of-destination .drts-view-entities-container:not(:last):not(.drts-load-more-container-active)").remove();
$(".places-of-destination .ad_container").remove();
//$(".places-of-destination .drts-view-entities-container:first-child)").remove();
} else {
$(".drts-view-entities-container:not(:last):not(.destinations-list-ec):not(.drts-load-more-container-active)").remove();
$(".drts-ajax.drts-load-more-container:first-child .ad_container:first").remove();
if ($(".destinations-list-ec").length) {
$(".drts-view-entities-container.destinations-list-ec .destination-container > *").remove();
}
}
$('.drts-view-entities-container').css("opacity","1");
$('.drts-view-entities-container').fadeIn(300);
if ($('.collection-tab').length) {
$('.collection-tab:visible:first').click();
}
updateDestinationsList();
if (loading_url) {
setTimeout(function(){
window.canLoadMore = true;
}, 1000);
$(".sp_loadmore").removeClass("hidden");
} else {
$(".sp_loadmore").addClass("hidden");
}
} else {
setTimeout(function(){
updateDrts();
}, 1000);
}
}
$(".sort-filter-action").unbind("click").on("click", function(){
if ($(".drts-view-nav-item-name-filter-collapse").length) {
$(".drts-view-nav-item-name-filter-collapse:first-of-type")[0].click();
}
window.canLoadMore = false;
window.lastDrtView = $(".drts-view-entities-container:last").html();
$(".drts-bs-modal-body .drts-view-filter-form").css("opacity","0");
$(".drts-bs-modal-body .drts-view-filter-form").css("transition",'opacity 0.5s ease-in-out');
$( ".drts-bs-modal-footer .drts-form-buttons" ).prepend( ""+signature_script.reset+"" );
if ($(".header-breadcrumb.breadcrumb-simple").length) {
$(".drts .drts-bs-modal-header .drts-bs-modal-title").html(
$("#stickThis a").html()
+
`
`+signature_script.filter+`
`+$(".breadcrumb_last").text()+`
`);
} else {
$(".drts .drts-bs-modal-header .drts-bs-modal-title").html(
$("#stickThis a").html()
+
`
`+signature_script.filter+" "+$("#breadcrumbs a:first-of-type").text()+`
`+$(".breadcrumb_last").text()+`
`);
}
$(".modal-reset-filters").unbind("click").click(function(e){
if ($(".drts-bs-card-body .drts-view-entities-sort").length) {
$(".drts-bs-card-body .drts-view-entities-sort")[0].click();
}
$.each($("#drts-modal .drts-view-filter-form .drts-bs-custom-control.drts-bs-custom-checkbox"), function(i, val) {
if ($(val).find("input").is(":checked")) {
$(val).find("label").click();
}
});
e.preventDefault();
return false;
});
$(".drts-form-field-radio-options .drts-bs-custom-checkbox input").prop("checked", false);
if ($("#drts-modal .drts-bs-card-body .drts-view-entities-sort").length) {
$("#drts-modal .drts-bs-card-body .drts-view-entities-sort").prop("onclick", "").attr("onclick", "").off("click");
$("#drts-modal .drts-bs-card-body .drts-view-entities-sort").click(function(event){
if ($(this).hasClass("activated")) {
//$(".drts-bs-card-body .drts-view-entities-sort").removeClass("activated");
} else {
$(".drts-bs-card-body .drts-view-entities-sort").removeClass("activated");
$(this).toggleClass("activated");
}
var filter_val = $(this).data("sort-value");
$(".filter-input-box").val(filter_val);
event.preventDefault();
return false;
});
//read sorting
$.each($("#drts-modal .drts-bs-card-body .drts-view-entities-sort"), function(i, val) {
var search = $(this).data("url").substring(1);
var value_ = JSON.parse('{"' + search.replace(/&/g, '","').replace(/=/g,'":"') + '"}', function(key, value) { return key===""?value:decodeURIComponent(value); });
var sort_setting_button = value_["sort"];
if ($(".drts-pagination .drts-bs-btn-outline-secondary.drts-bs-active + .drts-bs-btn-outline-secondary").length && $(".drts-pagination .drts-bs-btn-outline-secondary.drts-bs-active + .drts-bs-btn-outline-secondary").data("url")) {
search = $(".drts-pagination .drts-bs-btn-outline-secondary.drts-bs-active + .drts-bs-btn-outline-secondary").data("url").split("?")[1];
} else if ($(".sp_loadmore a").data("url")) {
search = $(".sp_loadmore a").data("url").split("?")[1];
} else {
search = false;
}
if (search) {
search_object = JSON.parse('{"' + search.replace(/&/g, '","').replace(/=/g,'":"').replace("%2C",',') + '"}', function(key, value) { return key===""?value:decodeURIComponent(value); });
search_object["sort"] = window.slctd_sort_setting;
var search_new = "";
for (var key in search_object) {
if (search_new != "") {
search_new += "&";
}
search_new += key + "=" + encodeURIComponent(search_object[key]);
}
search = search_new;
value_ = JSON.parse('{"' + search.replace(/&/g, '","').replace(/=/g,'":"').replace("%2C",',') + '"}', function(key, value) { return key===""?value:decodeURIComponent(value); });
var sort_setting_url = value_["sort"];
if (sort_setting_button == sort_setting_url) {
$(this).click();
$(this).addClass("activated");
}
}
});
if(!$("#drts-modal .drts-bs-card-body .drts-view-entities-sort.activated").length) {
$("#drts-modal .drts-bs-card-body .drts-view-entities-sort[data-filter-name='justin']").addClass("activated");
}
}
var url = $(".drts-view-entities-container:last-of-type .drts-pagination .drts-bs-btn-outline-secondary.drts-bs-active + .drts-bs-btn-outline-secondary").data("url");
if (typeof url === "undefined" && $(".sp_loadmore a").data("url")) {
url = $(".sp_loadmore a").data("url").split("?")[1];
}
if (typeof url !== "undefined" && !url.includes("filter_directory_category")) {
$(".drts-form-field-radio-option input").prop("checked", false);
}
if (typeof url === "undefined") {
var url = "";
}
//read filters
var count_filters = (url.match(/filter_directory_category/g) || []).length;
$.each($(".drts-form-field-radio-option"), function(i, val) {
if ( slctd_cat_ids.includes($(this).find("input").val()) ) { //$(this).find("input").is(":checked") ||
$(this).find("label").addClass("activated");
$(this).find("input").prop( "checked", true );
} else {
var check = false;
if (check) {
$(this).find("label").addClass("activated");
$(this).find("input").prop( "checked", true );
} else {
$(this).find("label").removeClass("activated");
$(this).find("input").prop( "checked", false );
}
}
});
setTimeout(function(){
window.filter_height = 0;
window.filter_i = 0;
$(".drts-form-field-radio-option.drts-bs-custom-control.drts-bs-custom-checkbox").each(function(){
window.filter_i++;
if ((!$(this).hasClass("two-rows")) && ($(this).innerHeight() > window.filter_height) && (window.filter_height > 0)) {
switch (window.filter_i) {
case 1:
case 2:
case 3:
$(".drts-form-field-radio-option.drts-bs-custom-control.drts-bs-custom-checkbox").eq(0).addClass("two-rows");
$(".drts-form-field-radio-option.drts-bs-custom-control.drts-bs-custom-checkbox").eq(1).addClass("two-rows");
$(".drts-form-field-radio-option.drts-bs-custom-control.drts-bs-custom-checkbox").eq(2).addClass("two-rows");
break;
case 4:
case 5:
case 6:
$(".drts-form-field-radio-option.drts-bs-custom-control.drts-bs-custom-checkbox").eq(3).addClass("two-rows");
$(".drts-form-field-radio-option.drts-bs-custom-control.drts-bs-custom-checkbox").eq(4).addClass("two-rows");
$(".drts-form-field-radio-option.drts-bs-custom-control.drts-bs-custom-checkbox").eq(5).addClass("two-rows");
break;
case 7:
case 8:
case 9:
$(".drts-form-field-radio-option.drts-bs-custom-control.drts-bs-custom-checkbox").eq(6).addClass("two-rows");
$(".drts-form-field-radio-option.drts-bs-custom-control.drts-bs-custom-checkbox").eq(7).addClass("two-rows");
$(".drts-form-field-radio-option.drts-bs-custom-control.drts-bs-custom-checkbox").eq(8).addClass("two-rows");
break;
case 10:
case 11:
case 12:
$(".drts-form-field-radio-option.drts-bs-custom-control.drts-bs-custom-checkbox").eq(9).addClass("two-rows");
$(".drts-form-field-radio-option.drts-bs-custom-control.drts-bs-custom-checkbox").eq(10).addClass("two-rows");
$(".drts-form-field-radio-option.drts-bs-custom-control.drts-bs-custom-checkbox").eq(11).addClass("two-rows");
break;
}
$(".drts-form-field-radio-option.drts-bs-custom-control.drts-bs-custom-checkbox").eq(window.filter_i - 1).addClass("two-rows-active");
}
window.filter_height = $(this).outerHeight();
});
$(".drts-bs-modal-body .drts-view-filter-form").css("opacity","1");
$(".drts-bs-modal-body .drts-view-filter-form").css("transition","0");
}, 300);
});
$(".js-toggle-hamburger").on("click", function () {
$(".js-toggle-hamburger").toggleClass("is-active");
});
$(".sidebar-toggle, .sidebar-toggle-only").on("click", function(){
toggleSidebar("right");
});
$(".topnav .widget_sabaiapps_directories_wordpress_directory_posts_directory__listing .widget-title, .topnav .widget-container.widget_sp_makersbrands_widget .widget-title").on("click", function () {
if (window.isMobile) {
$(this).parents(".widget-area").find(".drts-system-widget-directory-posts-directory--listing").toggle();
$(this).parents(".widget-area").find(".widget_nav_menu").toggle();
$(this).parents(".widget-area").toggleClass("menu-toggle");
}
});
function sticktothetopmobile() {
var window_top = $(window).scrollTop();
if (window_top >= 40) {
if (!$('#stickThis').hasClass('stick')) {
$('#stickThis').hide();
$('#stickThis').addClass('stick');
//$('#content').css('', ' ');
$( '#content' ).each(function () {
this.style.setProperty( 'padding-top', '5.5rem', 'important' );
});
$('#hideThisOnStick').hide();
$('#stickThis').fadeIn();
$('#stick-here').height($('#stickThis').outerHeight());
}
} else {
if ($('#stickThis').hasClass('stick')) {
$('#hideThisOnStick').fadeIn(100);
$('#stickThis').removeClass('stick');
$('#content').css('padding-top', '0');
$('#stick-here').height(0);
}
}
}
function sticktothetopdesktop() {
var window_top = $(window).scrollTop();
if (window_top >= 1) {
$("#topheader").css("background-color", "white");
$("#topheader").css("box-shadow", "0 2px 9px 0 rgba(41,54,52,0.1)");
} else {
$("#topheader").css("background-color", "transparent");
$("#topheader").css("box-shadow", "none");
}
}
function sticklistingtabs() {
var window_top = $(window).scrollTop();
if ($("#stickTabs").data("offset") > 0 ) { //&& $('#stickThis').hasClass('stick')
var tabs_offset = $("#stickTabs").data("offset");
} else {
var tabs_offset = $("#stickTabs").offset().top;
}
if ($("#wpadminbar").length) {
var adminbar_height = $("#wpadminbar").outerHeight();
} else {
var adminbar_height = 0;
}
if ($(".header-dynamic").length) {
var header_height = $(".header-dynamic > div").outerHeight();
} else {
var header_height = 0;
}
if (window_top + adminbar_height + header_height > $("#content").innerHeight()) {
if ($('#stickTabs').hasClass('stick')) {
$("#stickTabs .collection-tabs-inner-stick").css("width", "max-content");
$("#stickTabs").css("box-shadow", "none");
$("#stickTabs").css("border-top", "1px solid transparent");
$("#stickTabs").css("top", "unset");
$('#stickTabs').removeClass('stick');
}
}
else
if (window_top + adminbar_height + header_height >= tabs_offset) { // 64 +32
if (!$('#stickTabs').hasClass('stick')) {
$("#stickTabs").data("offset", $("#stickTabs").offset().top );
$("#stickTabs .collection-tabs-inner-stick").css("width", $("#stickTabs .collection-tabs-inner-stick").innerWidth() + 10);
$("#stickTabs").css("box-shadow", "0 3px 6px 0 rgba(41,54,52,0.1)");
$("#stickTabs").css("border-top", "1px solid rgba(41, 54, 52, 0.1)");
$("#stickTabs").css("top", (adminbar_height + header_height)+"px");
$('#stickTabs').addClass('stick');
$('#stickTabs').fadeIn();
}
} else {
if ($('#stickTabs').hasClass('stick')) {
$("#stickTabs .collection-tabs-inner-stick").css("width", "max-content");
$("#stickTabs").css("box-shadow", "none");
$("#stickTabs").css("border-top", "1px solid transparent");
$("#stickTabs").css("top", "unset");
$('#stickTabs').removeClass('stick');
}
}
}
function sticklistingad () {
var window_top = $(window).scrollTop();
var footer_offset = $(".site-footer").offset().top;
if (window.isMobile) {
var selector = ".dest-list-mobile-ad #stickAD";
} else {
var selector = ".dest-list-desktop-ad #stickAD";
}
$(selector).each(function(i, v){
if ($(this).is(":visible")) {
$(this).addClass("visible");
} else {
$(this).removeClass("visible");
}
});
$(selector).css("margin-top", 0);
$(selector).parents(".sticky_ad_container_parent").css("height", $(selector).outerHeight());
setTimeout(function(){
$(selector).parents(".sticky_ad_container_parent").css("height", $(selector).outerHeight());
}, 100);
if ($(selector).data("offset") > 0) {
var ad_offset = $(selector).data("offset");
} else {
try{
$(selector).data("offset", $(selector).offset().top)
var ad_offset = $(selector).offset().top;
}catch(e){
}
}
if (window_top + (64+40+58+$("#wpadminbar").outerHeight()) >= ad_offset && window_top+64+40+152 <= footer_offset - $(selector).outerHeight()) {
if (window.isMobile != true && !$(selector).hasClass('stick') ) {
var parentwidth = $(selector).width();
$(selector).css("top", (64+58+40+$("#wpadminbar").outerHeight())+"px");
$(selector).addClass('stick');var element = $(".dest-list-desktop-ad")[0];
var rt = window.innerWidth - element.getBoundingClientRect().right - 12;
} else if ($(selector).hasClass('stick') && window.isMobile) {
$(selector).css("top", "unset");
$(selector).removeClass('stick');
}
} else if (window.isMobile != true && window_top + 64+40+152 >= footer_offset - $(selector).outerHeight()) {
if ($(selector).hasClass('stick')) {
var top_pos = $(".destinations-list-with-ad-sidebar .ad-siderbar").outerHeight() - 152;
$(selector).css("top", top_pos);
$(selector).removeClass('stick');
}
} else {
if ($(selector).hasClass('stick')) {
$(selector).css("top", "unset");
$(selector).removeClass('stick');
}
}
}
function sticklistingadsearch () {
if (window.isMobile != true) {
var window_top = $(window).scrollTop();
try{
var footer_offset = $(".site-footer").offset().top;
}catch(e){
}
if (window.isMobile) {
var selector = ".dest-list-mobile-ad #stickADsearch";
} else {
var selector = ".dest-list-desktop-ad #stickADsearch";
}
$(selector).each(function(i, v){
if ($(this).is(":visible")) {
$(this).addClass("visible");
} else {
$(this).removeClass("visible");
}
});
$(selector).css("margin-top", 0);
$(selector).parents(".sticky_ad_container_parent").css("height", $(selector).outerHeight());
setTimeout(function(){
$(selector).parents(".sticky_ad_container_parent").css("height", $(selector).outerHeight());
}, 100);
if ($(selector).data("offset") > 0) {
var ad_offset = $(selector).data("offset");
} else {
try{
$(selector).data("offset", $(selector).offset().top)
var ad_offset = $(selector).offset().top;
}catch(e){
}
}
var topheader_height = $("#topheader").outerHeight();
var ad_height = $(selector).outerHeight();
var adminbar_height = $("#wpadminbar").outerHeight();
if (window_top + topheader_height + (adminbar_height) >= ad_offset - 32 && window_top + topheader_height + adminbar_height <= footer_offset - ad_height - 32) {
if (window.isMobile != true && !$(selector).hasClass('stick') ) {
var parentwidth = $(selector).width();
$(selector).css("top", (topheader_height+adminbar_height+32)+"px");
$(selector).addClass('stick');
var element = $(".dest-list-desktop-ad")[0];
var rt = window.innerWidth - element.getBoundingClientRect().right - 12;
} else if ($(selector).hasClass('stick') && window.isMobile) {
$(selector).css("top", "unset");
$(selector).removeClass('stick');
}
} else if (window.isMobile != true && window_top + topheader_height + adminbar_height >= footer_offset - ad_height - 32) {
if ($(selector).hasClass('stick')) {
var top_pos = $(".destinations-list-with-ad-sidebar .ad-siderbar").outerHeight() - ad_height + topheader_height + adminbar_height + 124;
$(selector).css("top", top_pos);
$(selector).removeClass('stick');
}
} else {
if ($(selector).hasClass('stick')) {
$(selector).css("top", "unset");
$(selector).removeClass('stick');
}
}
}
}
function scrollhidefilters () {
if (window.canLoadMore === true || !$(".sp_loadmore a").length || $(".sp_loadmore a").is(":hidden")) {
var window_top = $(window).scrollTop();
if (window.isMobile) {
var footer_offset = $(".site-footer").offset().top - $(".site-footer").innerHeight() + 480;
} else {
var footer_offset = $(".site-footer").offset().top - $(".site-footer").innerHeight() + 70;
}
if (window_top >= footer_offset) {
$(".sort-filter-container").fadeOut(300);
} else {
$(".sort-filter-container").fadeIn(300);
}
}
}
$(function() {
if ($(".big-hero-section").length) {
document.body.height = window.innerHeight;
if (window.isMobile) {
$(".big-hero-section").height(window.innerHeight - 50);
} else {
$(".big-hero-section").height(window.innerHeight - 50 - $("#content").offset().top);
}
}
if ($(".header-dynamic").length) {
if (window.isMobile) {
$(window).scroll(sticktothetopmobile);
sticktothetopmobile();
} else {
$(window).scroll(sticktothetopdesktop);
sticktothetopdesktop();
}
}
if ($(".sort-filter-container").length) {
$(window).scroll(scrollhidefilters);
scrollhidefilters();
}
if ($("#stickAD > .ad_container").innerWidth() > window.innerWidth / 2) {
$("#stickAD > .ad_container").css("max-width", window.innerWidth / 3);
}
if ($("#stickADsearch > .ad_container").innerWidth() > window.innerWidth / 2) {
$("#stickADsearch > .ad_container").css("max-width", window.innerWidth / 3);
}
if ($("#stickTabs").length) {
$(window).scroll(sticklistingtabs);
sticklistingtabs();
$("#stickTabs .collection-tabs-inner-stick").css("width", "max-content");
$("#stickTabs").css("box-shadow", "none");
$("#stickTabs").css("border-top", "1px solid transparent");
$("#stickTabs").css("top", "unset");
$('#stickTabs').removeClass('stick');
$(".js-listing-tab").click(function (e) {
$(".js-listing-tabs").data("is-click-scrolling", 1);
$(".js-listing-tab").removeClass("selected");
$(this).addClass("selected");
$(".js-listing-tabs").animate({scrollLeft: $(this)[0].offsetLeft - 16}, 800);
var orghref = $(this).find("a").attr("href");
if ($(orghref.replace(/[^a-zA-Z#]+/g, "")).length) {
if ($("#wpadminbar").length) {
var top = $(orghref.replace(/[^a-zA-Z#]+/g, "").replace("---", "-")).offset().top - ( $("#wpadminbar").outerHeight() + $("#topheader").outerHeight() + $("#stickTabs").outerHeight() );
} else {
var top = $(orghref.replace(/[^a-zA-Z#]+/g, "").replace("---", "-")).offset().top - ( $("#topheader").outerHeight() + $("#stickTabs").outerHeight() );
}
if (window.isMobile) {
if ($(".page-template-template-destinations").length) {
var scroll_top = top - 90;
} else {
var scroll_top = top - 45;
}
} else {
var scroll_top = top - 45;
}
$([document.documentElement, document.body]).animate({
scrollTop: scroll_top
}, 300 ).promise().done(function () {
setTimeout(function () {
$(".js-listing-tabs").data("is-click-scrolling", 0);
}, 2000);
});
}
e.preventDefault();
return false;
});
}
$.each($(".drts-display-element-with-link"), function (i, v) {
var href = $(this).parents(".drts-row.drts-gutter-none").find(".directory-listing-title a.drts-entity-permalink").attr("href");
if (null != href) {
$(".drts-display-element-with-link")[i].onclick = null;
$(this).parents(".drts-row.drts-gutter-none").unbind("click").click(function(event){
var href = $(this).find(".directory-listing-title a.drts-entity-permalink").attr("href");
if (event.ctrlKey) {
window.open(href, "_blank");
} else {
window.open(href, "_top");
}
});
}
});
if ($("#stickAD").length || $("#stickADsearch").length) {
if ($("#stickAD").length ) {
$(window).scroll(sticklistingad);
sticklistingad();
var selector = "#stickAD";
var selector_margin = ".headline-container";
} else if ($("#stickADsearch").length ) {
$(window).scroll(sticklistingadsearch);
sticklistingadsearch();
var selector = "#stickADsearch";
var selector_margin = ".site-footer .container";
}
if (!window.isMobile) {
$(".destinations-list-with-ad-sidebar > div:nth-child(1)").css("flex", "unset");
$(".destinations-list-with-ad-sidebar > div:nth-child(1)").css("max-width", "calc(100% - "+$(selector + " > .ad_container").innerWidth()+"px - 32px)");
$(".destinations-list-with-ad-sidebar > div:nth-child(1)").css("width", "calc(100% - "+$(selector + " > .ad_container").innerWidth()+"px - 32px)");
$(".destinations-list-with-ad-sidebar > div:nth-child(2)").css("flex", "unset");
$(".destinations-list-with-ad-sidebar > div:nth-child(2)").css("max-width", "calc("+$(selector + " > .ad_container").innerWidth()+"px )");
var or_ml = $(selector_margin).css("margin-right").replace('-','');
var marginRight = "-"+or_ml;
var marginLeft = or_ml;
$(".destlist-container").css("margin-right", marginRight);
$(".destlist-container").css("max-width", "calc("+ $(selector_margin).outerWidth() +"px + " + marginLeft.replace("px", "")+"px)");
$(".destlist-container").css("margin-left", marginLeft);
} else {
$(".destinations-list-with-ad-sidebar > div:nth-child(1)").css("flex", "0 0 100%");
$(".destinations-list-with-ad-sidebar > div:nth-child(1)").css("max-width", "100%");
$(".destinations-list-with-ad-sidebar > div:nth-child(1)").css("width", "100%");
$(".destinations-list-with-ad-sidebar > div:nth-child(2)").css("flex", "0 0 100%");
$(".destinations-list-with-ad-sidebar > div:nth-child(2)").css("max-width", "100%");
$(".destlist-container").css("margin-right", "auto");
$(".destlist-container").css("margin-left", "auto");
$(".destlist-container").css("max-width", "100%");
}
}
});
if ($(".featured-listing .white-bg-container").length) {
$.each($(".featured-listing .white-bg-container"), function(i, v){
$(this).height($(this).parents(".featured-listing").find(".listing-card:first").outerHeight());
});
}
if ($(".sp_loadmore a").length) {
var loading_url = $(".drts-pagination .drts-bs-btn-outline-secondary.drts-bs-active + .drts-bs-btn-outline-secondary").data("url");
var load_url = loading_url;
$(".sp_loadmore a").data("url", load_url);
//$(".drts-pagination .drts-bs-btn-outline-secondary.drts-bs-active + .drts-bs-btn-outline-secondary").data("url", load_url);
if (loading_url) {
window.canLoadMore = true;
$(".sp_loadmore").removeClass("hidden");
} else {
//disable load more
$(".sp_loadmore").addClass("hidden");
}
$(".sp_loadmore a").click(function () {
if (window.canLoadMore === true) {
window.canLoadMore = false;
$(this).show();
$(this).addClass("loading");
$('#main').find('.drts-view-entities-container:not(:last-of-type) .drts-view-entities-footer').remove();
var html = '';
$(".drts-load-more-container").removeClass("drts-load-more-container-active");
if ($(".container.load-more-container").length) {
var targ = ".drts-load-more-container-active";
var cont = ".container.load-more-container";
} else {
var targ = ".drts-load-more-container-active";
var cont = "#content > .container";
}
if ($(".places-of-destination").length) {
if ($(".places-of-destination .drts-load-more-container:last").length) {
$('#main').find('.places-of-destination .drts-load-more-container:last').after( html ).ready($(".places-of-destination .ad_container:last").show());
} else if ($(".places-of-destination .drts-view-entities-container:last-of-type").length) {
$('#main').find('.places-of-destination .drts-view-entities-container:last-of-type').after( html ).ready($(".places-of-destination .ad_container:last").show());
} else {
$('#main').find('.places-of-destination .drts-main > script').after( html ).ready($(".places-of-destination .ad_container:last").show());
}
} else {
if ($(".drts-load-more-container:last").length) {
$('#main').find('.drts-load-more-container:last').after( html ).ready($(".ad_container:last-of-type").hide());
} else {
$('#main').find('.drts-view-entities-container:last-of-type').after( html ).ready($(".ad_container:last-of-type").hide());
}
}
$this = $(this);
DRTS.ajax(
{
target:targ,
scroll:false,
cache:true,
pushState:false,
container:cont,
onContent: function onContent(res, tar, tri) {
if ($(".ad_container").length) {
$('.container:not(.list-without-pagination)').find(targ).prepend($(".ad_container")[0].outerHTML);
}
$(targ).hide();
$(".ad_container:last-of-type").fadeIn(300);
$(targ).fadeIn(300);
var loading_url = $(targ+" .drts-pagination .drts-bs-btn-outline-secondary.drts-bs-active + .drts-bs-btn-outline-secondary").data("url");
if (undefined !== loading_url) {
$(".sp_loadmore a").data("url", loading_url);
window.canLoadMore = true;
} else {
$(".sp_loadmore a").hide();
}
$(this).removeClass("loading");
},
trigger:jQuery(this)
});
}
});
}
if ($(".gallery").length) {
$(".gallery").addClass("flexbin flexbin-margin");
}
if ($(".makers-and-brands-featured").length) {
$(".makers-and-brands-featured:first .drts-main .drts-view-entities-list-grid > .drts-row > div:first-child").removeClass("drts-col-lg-6 drts-col-xl-4");
$(".makers-and-brands-featured:first .drts-main .drts-view-entities-list-grid > .drts-row > div:first-child").addClass("drts-col-lg-8 drts-col-xl-8");
}
if ($(".highlights-container").length) {
$(".highlights-container .drts-main").scrollLeft(0);
highlightedScroll("highlights-slider-instagram");
highlightedScroll("highlights-slider-places");
$(".highlights-container.highlights-slider-places .hl-see-all").appendTo(".container-fluid:not(.instagramfeed) .highlights-container .drts-main .drts-view-entities-container-list .drts-view-entities-list-row > .drts-row");
$(".highlights-container.highlights-slider-places .hl-see-all").css("width", $("body.home .highlights-container.highlights-slider-places .drts-view-post-entities.drts-view-entities-list .drts-row > div").outerWidth())
$(".hl-slide-controls .hl-slide-control-right").click(function(){
var slider = $(this).attr("data-slider");
var goalPos = ($("body.home .highlights-container."+slider+" .drts-view-post-entities.drts-view-entities-list .drts-row > div").outerWidth()) * 3;
$(".highlights-container."+slider+" .drts-main").animate({scrollLeft: $(".highlights-container."+slider+" .drts-main").scrollLeft() + goalPos});
});
$(".hl-slide-controls .hl-slide-control-left").click(function(){
var slider = $(this).attr("data-slider");
var goalPos = ($("body.home .highlights-container."+slider+" .drts-view-post-entities.drts-view-entities-list .drts-row > div").outerWidth()) * 3;
$(".highlights-container."+slider+" .drts-main").animate({scrollLeft: $(".highlights-container."+slider+" .drts-main").scrollLeft() - goalPos});
});
$(".highlights-slider-places .drts-main").scroll(function () {
highlightedScroll("highlights-slider-places");
});
$(".highlights-slider-instagram .drts-main").scroll(function () {
highlightedScroll("highlights-slider-instagram");
});
}
function updateDestinationsList () {
if ($(".page-template-template-destinations:not(.single)").length) {
$.each(destinations_data, function(index, value) {
if (value.length) {
var i = 0;
var is_empty = true;
var orgindex = index;
index = index.replace(/[^a-zA-Z]+/g, "").replace("---", "-");
$.each(value, function (index2, value2) {
if ($(".no-js-destinations .drts-entity[data-entity-id='"+value2["ID"]+"']").length && value2["count"] > 0) {
if (i==0) {
$(".destination-container").append(""+orgindex+"
");
$(".destination-container").append("");
}
$(".no-js-destinations .drts-entity[data-entity-id='"+value2["ID"]+"']").parents(".drts-col-12").detach().data("count", value2["count"]).appendTo(".destination-container > .drts-row:last-of-type");
is_empty = false;
i++;
}
});
if (is_empty) {
$(".collection-tab[data-collection-tab='"+index+"']").hide();
} else {
$(".collection-tab[data-collection-tab='"+index+"']").show();
}
/*
if ($('.destination-container > .drts-row:last-of-type .drts-col-12').length) {
$('.destination-container > .drts-row:last-of-type .drts-col-12').sort(function(a,b) {
if (parseFloat($(a).data('count')) > parseFloat($(b).data('count'))) {
return -1;
} else
if (parseFloat($(a).data('count')) < parseFloat($(b).data('count'))) {
return 1;
} else {
return 0;
}
}).appendTo('.destination-container > .drts-row:last-of-type');
}*/
}
});
if (!window.isMobile) {
if ($("#stickAD > .ad_container").innerWidth() > window.innerWidth / 2) {
$("#stickAD > .ad_container").css("max-width", window.innerWidth / 3);
}
if ($("#stickADsearch > .ad_container").innerWidth() > window.innerWidth / 2) {
$("#stickADsearch > .ad_container").css("max-width", window.innerWidth / 3);
}
$(".destinations-list-with-ad-sidebar > div:nth-child(1)").css("flex", "unset");
$(".destinations-list-with-ad-sidebar > div:nth-child(1)").css("padding-right", "2rem");
$(".destinations-list-with-ad-sidebar > div:nth-child(1)").css("max-width", "calc(100% - "+$("#stickAD > .ad_container").innerWidth()+"px - 32px)");
$(".destinations-list-with-ad-sidebar > div:nth-child(2)").css("flex", "unset");
$(".destinations-list-with-ad-sidebar > div:nth-child(2)").css("max-width", "calc("+$("#stickAD > .ad_container").innerWidth()+"px )");
var or_ml = $(".headline-container").css("margin-right").replace('-','') ;
var marginRight = "-"+or_ml;
var marginLeft = or_ml;
$(".destlist-container").css("margin-right", marginRight);
$(".destlist-container").css("max-width", "calc("+$(".headline-container").outerWidth() +"px + " + marginLeft.replace("px", "")+"px)");
$(".destlist-container").css("margin-left", marginLeft);
}
$('.collection-tab:visible:first').addClass("selected");
$(".destination-container div.dest-row .drts-display--summary-collection-list").unbind("click").click(function(e){
var href = $(this).find("a.drts-entity-permalink").attr("href");
if (event.ctrlKey) {
window.open(href, "_blank");
} else {
window.open(href, "_top");
}
e.preventDefault();
return false;
});
}
}
updateDestinationsList();
function highlightedScroll (slider) {
if ($(".highlights-container."+slider+" .drts-main").scrollLeft() == 0) {
$(".highlights-container."+slider+" .hl-slide-controls .hl-slide-control-left").hide();
} else
if ($(".highlights-container."+slider+" .drts-main")[0].scrollWidth - $(".highlights-container."+slider+" .drts-main").scrollLeft() == $(".highlights-container."+slider+" .drts-main").outerWidth()) {
$(".highlights-container."+slider+" .hl-slide-controls .hl-slide-control-right").hide();
} else {
$(".highlights-container."+slider+" .hl-slide-controls .hl-slide-control-left").show();
$(".highlights-container."+slider+" .hl-slide-controls .hl-slide-control-right").show();
}
}
var hideDelay = true;
$('body').on('hide.bs.modal', '.drts-bs-modal', function(e) {
window.drts_response = $("#drts-modal .drts-bs-modal-body").html();
window.slctd_cat_ids = [];
$.each($("#drts-modal .drts-form-field-radio-option"), function(i, val) {
if ($(this).find("input").prop("checked")) {
window.slctd_cat_ids.push($(this).find("input").val());
}
});
window.slctd_sort_setting = $("#drts-modal .drts-view-entities-sort.activated").data("sort-value");
});
$(window).scroll(function() {
loadMoreScroll();
onePageTabsScroll();
});
if ($(".card-section-single-childs").length) {
$(".card-section-single-childs").addClass("card-section-single-childs-"+$(".card-section-single-childs .drts-main > .drts-view-entities-container-list > .drts-view-entities-list > .drts-view-entities-list-row > .drts-row > div").length);
}
if ($(".single.drts-entity-post .directory-listing-headerphoto").length) {
$('.single.drts-entity-post .directory-listing-headerphoto img').imgLoad(function(){
if (window.isMobile) {
var w_ratio = 4;
var h_ratio = 3;
} else {
var w_ratio = 16;
var h_ratio = 9;
}
$(this).parents(".directory-listing-headerphoto").attr("style", "height: "+(this.width / w_ratio * h_ratio)+"px!important");
var w = $(this).parents(".directory-listing-headerphoto").outerHeight();
window.listingHeaderPhoto = w;
if (!window.isMobile) {
$(".single.drts-entity-post .drts-display-element-template-name-place_tabs").css("margin-top", w + "px");
}
$(".single.drts-entity-post .drts-display-element.single-listing-bottom-categories.single-place-top").css("margin-top", w + "px");
$(".drts-display-element-template-name-place_image_caption").css("margin-top", w + "px");
});
$('.single.drts-entity-post .directory-listing-headerphoto img').on("hover", function(){
// Get the current title
var title = $(this).attr("title");
// Store it in a temporary attribute
$(this).attr("tmp_title", title);
// Set the title to nothing so we don't see the tooltips
$(this).attr("title", "");
});
}
$("#content").css("visibility", "visible");
function loadMoreScroll () {
if ((!$("#drts-modal").length || $("#drts-modal").attr("aria-hidden") == "true" ) && !$("body").hasClass("noScroll")) {
if( $(".sp_loadmore").isInViewport() && window.canLoadMore === true ){
$(".sp_loadmore a").click();
}
}
}
function onePageTabsScroll() {
if ($(".js-listing-tabs").length && !$(".js-listing-tabs").data("is-click-scrolling")) {
var the_index = -1;
$.each($(".js-listing-tab"), function(i, v){
var orghref = $(this).find("a").attr("href");
if ($(orghref.replace(/[^a-zA-Z#]+/g, "")).length) {
if ($("#wpadminbar").length) {
var top = $(orghref.replace(/[^a-zA-Z#]+/g, "")).offset().top - ( $("#wpadminbar").outerHeight() + $("#topheader").outerHeight() + $("#stickTabs").outerHeight() );
} else {
var top = $(orghref.replace(/[^a-zA-Z#]+/g, "")).offset().top - ( $("#topheader").outerHeight() + $("#stickTabs").outerHeight() );
}
if ($(window).scrollTop() > top) {
the_index = i;
}
}
});
if(the_index !== -1) {
setTimeout(function(){
if (!$(".js-listing-tabs").data("is-click-scrolling")) {
$(".js-listing-tab").removeClass("selected");
$(".js-listing-tab").eq(the_index).addClass("selected");
$(".js-listing-tabs").scrollLeft($(".js-listing-tab").eq(the_index)[0].offsetLeft - 16);
}
}, 100);
}
}
}
function toggleSidebar(side) {
if (side !== "right") {
return false;
}
var right = $("#topnav-container"),
content = $("#main-container"),
openSidebarsCount = 0,
contentClass = "";
if (side === "right") {
right.toggleClass("collapsed");
$("body").toggleClass("noScroll");
}
closeSearchBar();
if (right.hasClass("collapsed")) {
$("#topnav-toggle").addClass("hide-it");
$("#topnav-toggle").fadeOut(300, function() {
$("#sidebar-toggle-inner-container").show();
});
} else {
$("#topnav-toggle").removeClass("hide-it");
$("#topnav-toggle").fadeIn(300, function() {
$("#sidebar-toggle-inner-container").hide();
});
}
}
if ($("#stickAD").length || $("#stickADsearch").length) {
var targetNodes = $("#stickAD .ad_container, #stickADsearch .ad_container");
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
var myObserver = new MutationObserver (mutationHandler);
var obsConfig = { childList: true, characterData: true, attributes: true, subtree: true };
//--- Add a target node to the observer. Can only add one node at a time.
targetNodes.each ( function () {
myObserver.observe (this, obsConfig);
} );
function mutationHandler (mutationRecords) {
$(window).trigger('resize');
}
}
});
/**
* Trigger a callback when 'this' image is loaded:
* @param {Function} callback
*/
(function($){
$.fn.imgLoad = function(callback) {
return this.each(function() {
if (callback) {
if (this.complete || /*for IE 10-*/ $(this).height() > 0) {
callback.apply(this);
}
else {
$(this).on('load', function(){
callback.apply(this);
});
}
}
});
};
})(jQuery);